@echo off
chcp 65001 >nul 2>&1
title DataPlexus Installation Script

echo ================================================================
echo                    DataPlexus Installation
echo                  Data Lineage Analysis System
echo ================================================================
echo.

:: Check Python
echo [1/4] Checking Python...
python --version >nul 2>&1
if errorlevel 1 (
    echo ERROR: Python not found. Please install Python 3.8+
    echo Download: https://www.python.org/downloads/
    pause
    exit /b 1
)
for /f "tokens=2" %%i in ('python --version 2^>^&1') do echo OK: Python %%i

:: Check Node.js
echo [2/4] Checking Node.js...
node --version >nul 2>&1
if errorlevel 1 (
    echo ERROR: Node.js not found. Please install Node.js 16+
    echo Download: https://nodejs.org/
    pause
    exit /b 1
)
for /f %%i in ('node --version') do echo OK: Node.js %%i

:: Install Backend Dependencies
echo [3/4] Installing backend dependencies...
cd backend
echo Installing Python packages...
pip install -r requirements.txt
if errorlevel 1 (
    echo ERROR: Failed to install backend dependencies
    pause
    exit /b 1
)
echo OK: Backend dependencies installed
cd ..

:: Install Frontend Dependencies
echo [4/4] Installing frontend dependencies...
cd frontend
echo Installing Node.js packages...
npm install
if errorlevel 1 (
    echo ERROR: Failed to install frontend dependencies
    pause
    exit /b 1
)
echo OK: Frontend dependencies installed
cd ..

:: Show completion message
echo.
echo ================================================================
echo                    Installation Complete!
echo ================================================================
echo.
echo All dependencies have been installed successfully.
echo You can now run the system using:
echo   - start-simple.bat (recommended)
echo   - start.bat (full menu)
echo.
echo Press any key to exit...
pause >nul

exit /b 0
